import api from '../../fetch/api'
import Vue from 'vue'
import App from '../../App'
import YDUI from 'vue-ydui';
Vue.use(YDUI);

function openOrderOpera(sta, orderId, source, token, id) {
	let ordermsg = ''
	let ajaxData = {
		source: source, //string	是			
		token: token, //string	是			
		userId: id, //string	是			
		orderId: orderId, //string	是			
		type: 0, //string	是	1取消预约2取消支付3删除(见详细说明)
	}
	if(sta == 0) {
		ajaxData.type = 1;
		console.log(ajaxData)
		ordermsg = "你是否要取消订单申请，取消后如果所选日期被出租，将无法再次预定，确认是否取消";
	}
	if(sta == 1 || sta == 2) {
		ajaxData.type = 2;
		ordermsg = "取消预约";
	}
	if(sta >= 5) {
		ajaxData.type = 3;
		ordermsg = "删除";
		//		this.ordermsg = this.orderclose;
	}
	this.$dialog.confirm({
		title: '提示',
		mes: ordermsg,
		opts: () => {
			api.GetOrderUser(ajaxData)
				.then(res => {
					console.log(res)
					this.$dialog.toast({
						mes: res.msg,
						timeout: 1000
					})
					return res.sta;
				})
		}
	});
}

export default {
	openOrderOpera

}